<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript异步编程</title>
    <script src="./js/js08_async_timer.js" async></script>
    <link rel="stylesheet" href="./style/common.css">
</head>
<body>
    <h1>异步：事件、定时器</h1>
    <p>定时器：setTimeout / setInterval</p>
    <p class="msg"></p>
    <p>
        <button>异步函数执行</button>
        <textarea name="" id="" cols="30" rows="10">
            点击“异步函数执行”后UI界面可以响应，不产生阻塞。
        </textarea>
    </p>
    <p class="timer"></p>
    <script>
        document.addEventListener("DOMContentLoaded",function(){
            let msg = document.querySelector(".msg");
            const btn = document.querySelector("button");
            btn.addEventListener("click",function(){
                setTimeout(function(){
                    done(msg,100000000,0);
                },0);
                
                let pElem = document.createElement("p");
                pElem.textContent = "新增段落";
                document.body.appendChild(pElem);
            });

            let dispTimer = document.querySelector(".timer");
            setInterval(function(){
                dispTimer.textContent = new Date().toLocaleTimeString();
            },1000)

            setInterval((msg)=>{
                console.log(msg);
            },1000,"更多参数");
        });
    </script>
</body>
</html>